package com.macken.zjh;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;

public class Renderer {

	TextureRegion bg;
	
	OrthographicCamera cam;
	SpriteBatch batch = new SpriteBatch(100);

	public Renderer() {
		bg = load("bg.png", 800, 480);
	}

	public static TextureRegion load(String name, int width, int height) {
		Texture texture = new Texture(Gdx.files.internal(name));
		TextureRegion region = new TextureRegion(texture, 0, 0, width, height);
		return region;
	}

	public void draw(TextureRegion region, int x, int y) {
		int width = region.getRegionWidth();
		if (width < 0)
			width = -width;
		batch.draw(region, x, y, Stats.instance.convertWidth(width), Stats.instance.convertHeight(region.getRegionHeight()));
	}

	public void draw(TextureRegion region, int x, int y, int width, int height) {
		batch.draw(region, x, y, 0, 0, width, height, 1, 1, 0);
	}

	public void render(float deltaTime) {
		batch.begin();
		draw(bg, 0, 0);
		batch.end();
	}
}
